<template>
    <div id="app" class="scroll theme-b" v-bind="{'minWidth':this.$route.name!='invitelogin'}">
        <router-view class="view"></router-view>
        <z-modal :msgs="msg"></z-modal>
    </div>
</template>

<script>
    import {appService} from './service/appService'
    import {loginService} from './service/loginService'
    import MeScroll from 'mescroll'
    let g = global || window
    g.scroll = MeScroll
    export default {
        name: 'app',
        data() {
            return{
                nocommon:null,
                loginIs:null,
                noinvite:false
            }
        },
        computed:{
            msg(){
                return this.$store.state.msg || {}
            }
        },
        watch: {
            '$route' (to,from) {
                const that = this;
                that.hasCommon();
                that.loginWay();
                that.hasInvite();
            }
        },
        mounted: function () {
            this.hasCommon()
            this.loginWay();
            this.hasInvite()
            appService.onBridgeReady()
            if(appService.checkLogin()){
                let JWT = localStorage.token.split('.');
                let info = JWT[1];
                loginService.packageUserInfo(info);
            }
        },
        methods: {
            goRegister:function(){
                this.$router.push({name:'register'})
            },
            loginWay:function(){
                if(localStorage.token && localStorage.token!='undefined'){
                    this.loginIs = true
                } else {
                    this.loginIs = false
                }
            },
            hasCommon:function(){
                const that = this
				if(that.$route.name == 'bindwxlogin' || that.$route.name == 'payok' || that.$route.name == 'invitelogin' || that.$route.name == 'invitecode' || that.$route.name == 'inviterule' || that.$route.name == 'alipay' || that.$route.name == 'paySuccess'){
                    that.nocommon = 1
                } else{
                    that.nocommon = 0
                }
            },
            hasInvite:function(){
                const that = this
				if(that.$route.name == 'paySuccess' || that.$route.name == 'bindwxlogin' || that.$route.name == 'payok' || that.$route.name == 'invitelogin' || that.$route.name == 'invitecode' || that.$route.name == 'inviterule' || that.$route.name == 'alipay' || that.$route.name == 'paySuccess'){
                    that.noinvite = true
                } else{
                    that.noinvite = false
                }
            }
        }
    }
</script>

<style lang="less">
    @import url('assets/css/base.less');
    @import url('assets/css/theme.less');
    @import url('assets/css/icon/iconfont.css');
    #mescroll{
        position: fixed;
        top:0;
        bottom: 0;
        left:0;
        right:0;
    }
    .hasfooter{
        padding-bottom:1.5rem!important;
        box-sizing:border-box;
    }
</style>
